(function() { let SNSType = function() { } SNSType.prototype.KAKAOTALK = "SNSTYPE_1"; SNSType.prototype.KAKAOSTORY = "SNSTYPE_2"; SNSType.prototype.NAVERBLOG = "SNSTYPE_3"; SNSType.prototype.NAVERLINE = "SNSTYPE_4"; SNSType.prototype.FACEBOOK = "SNSTYPE_5"; SNSType.prototype.INSTAGRAM = "SNSTYPEE_6"; SNSType.prototype.CLIPBOARD = "SNSTYPE_100"; let SNSShare = function() { this._isApp = false; this._imageUrl = ""; this._title = ""; this._shareUrl = ""; this._desc = ""; } SNSShare.prototype = { isApp : function(isApp) { this._isApp = isApp; return this; }, imageUrl : function(imageUrl) { this._imageUrl = imageUrl; return this; }, title : function(title) { this._title = title; return this; }, shareUrl : function(shareUrl) { this._shareUrl = shareUrl; return this; }, desc : function(desc) { this._desc = desc; return this; }, _kakaotalkShare : function () { let _this = this; let apiKey = ''; const dispMallNo = window.UIPage.dispMallNo; switch (dispMallNo) { case '0000014': // e-mall apiKey = '5d7cb86429415b83f4238200affa9f24'; break; case '0000113': // kidikidi apiKey = '99578dd847b57e3fc3701cd9ed9d95fb'; break; case '0000053': // shoopen apiKey = '451ad93dd77fac4b462614482f17df72'; break; case '0000125': // uptomax apiKey = '9550af20b420a3d93e262f878fadeecd'; break; default: apiKey = '5d7cb86429415b83f4238200affa9f24'; } Kakao.cleanup(); Kakao.init(apiKey); Kakao.Share.sendDefault({ objectType: 'feed', content: { title: _this._title, description: _this._desc, imageUrl: _this._imageUrl, link: { mobileWebUrl: _this._shareUrl, webUrl: _this._shareUrl } }, buttons: [ { title: '웹으로 이동', link: { mobileWebUrl: _this._shareUrl, webUrl: _this._shareUrl } }, { title: '앱으로 이동', link: { androidExecutionParams: _this._shareUrl, iosExecutionParams: _this._shareUrl } } ] }); }, _kakaostoryShare : function() { let _this = this; Kakao.cleanup(); Kakao.init('5d7cb86429415b83f4238200affa9f24'); Kakao.Story.cleanup(); if(window.UIPage.mediaDcode == '10'){ // pc Kakao.Story.share({ url: _this._shareUrl, text: _this._title }); } else { // mo, app Kakao.Story.open({ url: _this._shareUrl, text: _this._title }); } }, _urlShare : function(url) { let _this = this; if(_this._isApp) { window.location.href = "elandbridge://browser/?loadurl="+encodeURIComponent(url+_this._shareUrl); } else { window.open(url+_this._shareUrl,"_blank"); } }, _naverblogShare : function() { let _this = this; _this._urlShare("https://blog.naver.com/openapi/share?serviceCode=share&url="); }, _naverlineShare : function() { let _this = this; _this._urlShare("https://line.me/R/msg/text/?"); }, _facebookShare : function() { let _this = this; _this._urlShare("https://wwww.facebook.com/sharer.php?u="); }, _instagramShare : function() { let _this = this; _this._urlShare("https://www.instagram.com/?url="); }, _clipboardShare : function() { navigator.clipboard.writeText(this._shareUrl).then( () => { alert('복사되었습니다.'); }, () => { alert('복사실패했습니다.'); } ); }, build : function(type) { // console.log("type", type); let _this = this; switch (type) { case window.SNSType.KAKAOTALK : _this._kakaotalkShare(); break; case window.SNSType.KAKAOSTORY : _this._kakaostoryShare(); break; case window.SNSType.NAVERBLOG : _this._naverblogShare(); break; case window.SNSType.NAVERLINE : _this._naverlineShare(); break; case window.SNSType.FACEBOOK : _this._facebookShare(); break; case window.SNSType.INSTAGRAM : _this._instagramShare(); break; case window.SNSType.CLIPBOARD : _this._clipboardShare(); break; default : alert("입력하신 유형은 공유기능을 지원하지 않습니다."); break; } //20230223 marketingScript 통일 //if(window.UIPage.isApp === 'Y') { // Flutter.share(); //} var share_detail = { url: _this._shareUrl } shareClick(share_detail); } } window.SNSType = new SNSType(); window.SNSShare = new SNSShare(); })(); (function() { $(function () { var win = window; // Mo var $Layer = $('#SnsShareLayer'); $Layer.find('.pop-txt-sns-list li a').on('click', function (e) { e.preventDefault(); var $t = $(e.currentTarget); var type = $t.attr("class"); SNSShare.shareUrl(win.location.href); switch (type) { case "fb" : SNSShare.build(SNSType.FACEBOOK); break; case "ks" : SNSShare.build(SNSType.KAKAOSTORY); break; case "nb" : SNSShare.build(SNSType.NAVERBLOG); break; case "ln" : SNSShare.build(SNSType.NAVERLINE); break; case "kt" : SNSShare.build(SNSType.KAKAOTALK); break; case "is" : SNSShare.build(SNSType.INSTAGRAM); break; case "ur" : SNSShare.build(SNSType.CLIPBOARD); break; default : break; } }); // Pc $(".sns_list li a").on("click", function (e) { e.preventDefault(); var $t = $(e.currentTarget); var type = $t.parent().attr("class"); SNSShare.shareUrl(win.location.href); switch (type) { case "facebook" : SNSShare.build(SNSType.FACEBOOK); break; case "kakao" : SNSShare.build(SNSType.KAKAOSTORY); break; case "blog" : SNSShare.build(SNSType.NAVERBLOG); break; case "url" : SNSShare.build(SNSType.CLIPBOARD); break; default : break; } }); }); })();